// 浏览量数字格式化

export const formatCount = count => {
    if (count >= 100000000) {
        count /= 100000000
        return count.toFixed(1) + '亿';
    } else if (count >= 10000 && count < 99999999) {
        count /= 1000
        return count.toFixed(1) + '万';
    } else {
        return count;
    }
}

export const formatTime = timeStamp => {
    if (!timeStamp || isNaN(Number(timeStamp))) {
        return '--';
    }
    
    const dateObj = new Date(Number(timeStamp));
    
    return dateObj.getFullYear() + '年' + (dateObj.getMonth() + 1) + '月' + dateObj.getDate() + '日';
}

export const convertTimeStringToTimeStamp = timeString => {
    if (!timeString) {
        return 0;
    }
    const timeArr1 = timeString.trim().split(/(\:|\.)/).filter(_ => ![':', '.'].includes(_)).map(_ => Number(_));
    const result = timeArr1[0] * 6 * 1e4 + timeArr1[1] * 1e3 + timeArr1[2]
    return result;
}